cmake_minimum_required(VERSION 3.2)
find_package(OpenGL REQUIRED)
find_package(GLUT REQUIRED)
find_package(GLEW REQUIRED)
find_package(GDAL REQUIRED)


SET(SIFTGPU_ENABLE_OPENCL FALSE)
SET(SIFTGPU_ENABLE_CUDA FALSE)
SET(SIFTGPU_ENABLE_SSE TRUE)
SET(SIFTGPU_SSE_OPTIONS -march=core2 -mfpmath=sse)
SET(SIFTGPU_PREFER_GLUT TRUE)
SET(SIFTGPU_DISABLE_DEVIL FALSE)

SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -Wall -Wno-deprecated" )

IF(SIFTGPU_ENABLE_SSE)
  SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=core2 -mfpmath=sse" )
ENDIF(SIFTGPU_ENABLE_SSE)
  
IF(SIFTGPU_PREFER_GLUT)
  SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DWINDOW_PREFER_GLUT" )
ENDIF(SIFTGPU_PREFER_GLUT)

IF(SIFTGPU_ENABLE_OPENCL)
  SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DCL_SIFTGPU_ENABLED" )
ENDIF(SIFTGPU_ENABLE_OPENCL)

IF(APPLE)
  SET(LIBS_SIFTGPU )
ELSE(APPLE)
  SET(LIBS_SIFTGPU glut GL X11 )
ENDIF(APPLE)

IF(SIFTGPU_DISABLE_DEVIL)
  SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DSIFTGPU_NO_DEVIL" )
ELSE(SIFTGPU_DISABLE_DEVIL)
  SET(LIBS_SIFTGPU ${LIBS_SIFTGPU} IL )
ENDIF(SIFTGPU_DISABLE_DEVIL)

if (GLEW_FOUND)
	include_directories( ${GLEW_INCLUDE_DIRS} )
	SET (GLEW_LIBRARIES GLEW)
endif (GLEW_FOUND)

set(SIFTLIST FrameBufferObject.cpp GlobalUtil.cpp GLTexImage.cpp ProgramGLSL.cpp
        ProgramGPU.cpp ShaderMan.cpp SiftGPU.cpp SiftPyramid.cpp PyramidGL.cpp SiftMatch.cpp)
ADD_LIBRARY(siftgpu SHARED ${SIFTLIST})

TARGET_LINK_LIBRARIES(siftgpu ${LIBS_SIFTGPU} ${GLEW_LIBRARIES} ${GLUT_LIBRARIES} ${OPENGL_LIBRARIES} ${GDAL_LIBRARIES})

